In programming languages, implementation of generics is based on reification or erasure. Reification is a technique of compiling generics to a type specialized to the values of type parameters. Typical languages that adopt it are C++ and X10. For the characteristics and language specifications of X10.
Erasure is a technique of compiling generics to a common type in which type parameters are removed. Typical languages that adopt it are Java® and Scala. With erasure, since type parameters are removed after being checked during compiling, the values of the type parameters cannot be referred to at run-time. Accordingly, functions that depend on the values of type parameters at run-time (run-time type information), such as dispatch, cannot be implemented, so that the feature of erasure-based generics is a subset of the feature of reification-based one. Accordingly, conversion of a language that adopts generics based on reification to Java® generics based on erasure requires expressing run-time type information in one form or another.
For dispatch, a name mangling technique of encoding type information to a method name is used for a normal method. Since this technique can use Java® dispatch, high-speed dispatch is possible. Furthermore, the result of conversion depends only on the type of the parameters of the conversion target method, thus allowing stable conversion independent of other changes.
For constructors, a parameter mangling technique of encoding type information to the parameters of constructors is used because the names of constructors cannot be freely changed.
Compiling X10 source code to Java® source code or bytecode has been performed in the related art. In the related art, the order of implementation (0th, 1st, . . . ) of the conversion target constructor among constructors in the same class is encoded to the dimension of a multidimensional array of the type that does not generally appear in the parameters of constructors in X10, and a dummy parameter of the type is added. This enables high-speed dispatch because Java® dispatch can be used. However, this is based on a relative value, that is, the order of implementation of the constructor, thus causing instability of the conversion result being changed due to addition or deletion of another constructor in the same class. This causes problems when a complied library is provided in a binary form or when external (non-X10) Java code for calling Java® code generated by an X10 compiler is described.
For processing class constructors, the following related art is known.
Japanese Unexamined Patent Application Publication No. 9-190349 discloses a method for increasing a program execution speed by determining a class in which a source program described in C++ can be optimized, translating the member functions of the class to an intermediate expression, thereafter generating a code generating routine described in C++, embedding the generated code generating routine in constructors, and determining whether optimization of all classes has been finished and, if it is determined that it has been finished, completing the process.
Japanese Unexamined Patent Application Publication No. 2000-250755 discloses a method comprising the steps of detecting a keyword for identifying an adaptive class by analyzing an application source file, wherein if the adaptive class includes an adaptive software method, and when generating a first instance of the adaptive class, expanding constructors in the adaptive class by inserting a first instruction set for generating a selector that dynamically selects one of a large number of implementations of the adaptive software method to the application source file.
However, such related art does not solve the instability of dispatch when a code written in a programming language based on reification is converted to a code in a programming language based on erasure.
WebSphere® extreme Scale adopts a parameter mangling technique of adding dummy parameters of the same number as the order of definition of the constructor (continuous integers starting from 0). However, this technique has a problem in that stable dispatch is impossible because the order of definition of the constructor is a relative value and can be changed due to the order of addition of another constructor. Furthermore, using a plurality of dummy parameters wastes stacks, thus reducing efficiency.
Furthermore, the existing X10 adopts a parameter mangling technique of adding a dummy parameter of a multidimensional array in the same dimension as the order of definition of the constructor (continuous integers starting from 0). In this case, there is also a problem in that stable dispatch is impossible because the order of definition of the constructor is a relative value and can be changed due to addition or deletion of another constructor.
Another existing method for X10 is a method of self dispatch based on the values of parameters, that is, run-time type information, in which case JVM dispatch cannot be used, thus causing a delay of dispatch.